Skip to content

Update rules to align with WordPress Coding Standards 3.4.0/3.4.1 - #2

Open
ai-anant wants to merge 2 commits into
CodeVigilant:mainfrom
ai-anant:wpcs-3.4-updates
Open

Update rules to align with WordPress Coding Standards 3.4.0/3.4.1#2
ai-anant wants to merge 2 commits into
CodeVigilant:mainfrom
ai-anant:wpcs-3.4-updates

Conversation

@ai-anant

Copy link
Copy Markdown

Summary

Updates semgrep rules to align with the recent WordPress Coding Standards v3.4.0 (released 2026-07-14) and v3.4.1 (security release 2026-07-27).

Changes Made

1. New WP 7.0.0 deprecated functions (deprecated.yaml)

Added the three functions deprecated in WordPress 7.0.0 per WPCS v3.4.0:

Deprecated Replacement
addslashes_gpc() wp_slash()
block_core_navigation_block_contains_core_navigation() block_core_navigation_block_tree_has_block_type()
wp_sanitize_script_attributes() wp_get_script_tag() / wp_get_inline_script_tag()

2. New rule: @parse_url() error suppression (silenced-errors/parse_url.yaml)

WPCS v3.4.0 removed parse_url() from the NoSilencedErrors allowed list, meaning @parse_url() is now flagged. Also includes @unserialize() detection.

3. User-controlled version parameters in enqueued resources (enqueued-resources.yaml)

Related to the GHSA-3pwp-g2mj-5p3v security advisory fixed in v3.4.1. Detects user input in wp_enqueue_script() / wp_enqueue_style() version parameters.

Validation

  • All 120 rules validated with semgrep --validate — zero errors
  • Tested against sample PHP code — all new rules fire correctly on intended patterns

ai-anant added 2 commits July 28, 2026 11:25
Changes based on WPCS v3.4.0 (2026-07-14) and v3.4.1 security release (2026-07-27):

1. Add WP 7.0.0 deprecated functions to deprecated.yaml
   - addslashes_gpc() -> wp_slash()
   - block_core_navigation_block_contains_core_navigation()
     -> block_core_navigation_block_tree_has_block_type()
   - wp_sanitize_script_attributes()
     -> wp_get_script_tag() or wp_get_inline_script_tag()

2. New rule: silenced-errors/parse_url.yaml
   - WPCS 3.4.0 removed parse_url() from the allowed error suppression list
   - Flags @parse_url() usage
   - Also includes @unserialize() detection

3. Enqueued-resources.yaml: add user-controlled version param rule
   - Detects user input (//) in
     wp_enqueue_script() and wp_enqueue_style() version params
   - Related to EnqueuedResourceParametersSniff security advisory (GHSA-3pwp-g2mj-5p3v)
- Fix inline_script_tag/inline_style_tag: patterns were using unterminated
  PHP string literals and HTML-entity-corrupted versions, both non-functional.
  Switched to pattern-regex for <script and <link detection.
- Fix enqueued-resources message: user input in ANY argument position is
  detected (not just version param), so message now reflects that.
- Fix @unserialize rule: WPCS still allows it in its suppression list;
  added notes field documenting this is defense-in-depth.
- Remove duplicate get_user_by_email pattern in deprecated.yaml (pre-existing)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant